package json.gson;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

/**
 * @describe:
 * @Date: 2020/11/27 0027 10:25
 * @version: 0。1
 */
public class T1 {

    static String json = "{\n" +
            "    \"log_id\": 2648325511,\n" +
            "    \"direction\": 0,\n" +
            "    \"image_status\": \"normal\",\n" +
            "    \"edit_tool\": \"Adobe Photoshop CS3 Windows\",\n" +
            "    \"photo\": \"/9j/4AAQSkZJRgABA......\",\n" +
            "    \"photo_location\": {\n" +
            "        \"width\": 1189,\n" +
            "        \"top\": 638,\n" +
            "        \"left\": 2248,\n" +
            "        \"height\": 1483\n" +
            "    },\n" +
            "    \"words_result\": {\n" +
            "        \"住址\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 267,\n" +
            "                \"top\": 453,\n" +
            "                \"width\": 459,\n" +
            "                \"height\": 99\n" +
            "            },\n" +
            "            \"words\": \"南京市江宁区弘景大道3889号\"\n" +
            "        },\n" +
            "        \"公民身份号码\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 443,\n" +
            "                \"top\": 681,\n" +
            "                \"width\": 589,\n" +
            "                \"height\": 45\n" +
            "            },\n" +
            "            \"words\": \"330881199904173914\"\n" +
            "        },\n" +
            "        \"出生\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 270,\n" +
            "                \"top\": 355,\n" +
            "                \"width\": 357,\n" +
            "                \"height\": 45\n" +
            "            },\n" +
            "            \"words\": \"19990417\"\n" +
            "        },\n" +
            "        \"姓名\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 267,\n" +
            "                \"top\": 176,\n" +
            "                \"width\": 152,\n" +
            "                \"height\": 50\n" +
            "            },\n" +
            "            \"words\": \"伍云龙\"\n" +
            "        },\n" +
            "        \"性别\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 269,\n" +
            "                \"top\": 262,\n" +
            "                \"width\": 33,\n" +
            "                \"height\": 52\n" +
            "            },\n" +
            "            \"words\": \"男\"\n" +
            "        },\n" +
            "        \"民族\": {\n" +
            "            \"location\": {\n" +
            "                \"left\": 492,\n" +
            "                \"top\": 279,\n" +
            "                \"width\": 30,\n" +
            "                \"height\": 37\n" +
            "            },\n" +
            "            \"words\": \"汉\"\n" +
            "        }\n" +
            "    },\n" +
            "    \"words_result_num\": 6\n" +
            "}";

    public static void main(String[] args) {
        JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
        jsonObject = jsonObject.get("words_result").getAsJsonObject();
        System.out.println(jsonObject);
        String a = getWords(jsonObject, "住址");
        System.out.println(a);
    }

    public static String getWords(JsonObject jsonObject, String key){
        JsonObject jsonObjectW = jsonObject.get(key).getAsJsonObject();
        return jsonObjectW.get("words").getAsString();
    }

}
